#include "Rect3D.h"

#include "../../OpenGL.h"
#include "../GameLib.h"

Rect3D::Rect3D(){dirB=0.0;}
Rect3D::Rect3D(Point3D pt,double width,double height){
    location=pt;
    this->width=width;
    this->height=height;
    dirB=0.0;
}
Rect3D::Rect3D(Point3D pt, double width, double height, Direction3D d, double dd){
    location = pt;
    this->width=width;
    this->height=height;
    dir = d;
    dirB = dd;
}
Rect3D::~Rect3D(){}
void Rect3D::makePts(Point3D &b, Point3D &c, Point3D &d){
    b=location;
    b.move(dir,width);
}
double Rect3D::getDirB(){
    return dirB;
}
Rect3D& Rect3D::setDirB(double dd){
    dirB=dd;
    return *this;
}
double Rect3D::getWidth(){
    return width;
}
double Rect3D::getHeight(){
    return height;
}
Rect3D& Rect3D::setWidth(double width){
    this->width=width;
    return *this;
}
Rect3D& Rect3D::setHeight(double height){
    this->height=height;
    return *this;
}
void Rect3D::drawSolid(){
    Point3D b,c,d;
    makePts(b, c, d);
    
    glBegin(GL_QUADS);
    location.useAsVertex();
    b.useAsVertex();
    c.useAsVertex();
    d.useAsVertex();
    glEnd();
}
void Rect3D::drawSolid_color(int hexColor){
    float c[4];
    gameLib.getColorA(c);
    gameLib.setColor(hexColor);
    drawSolid();
    gameLib.setColorA(c);
}
void Rect3D::drawPerim(){
    Point3D b,c,d;
    makePts(b, c, d);
    
    glBegin(GL_LINES);
    location.useAsVertex();
    b.useAsVertex();
    c.useAsVertex();
    d.useAsVertex();
    glEnd();
}
void Rect3D::drawPerim_color(int hexColor){
    float c[4];
    gameLib.getColorA(c);
    gameLib.setColor(hexColor);
    drawPerim();
    gameLib.setColorA(c);
}
void Rect3D::drawPerim_width(double width){
    gameLib.setLineWidth(width);
    drawPerim();
}
void Rect3D::drawPerim_widthColor(double width, int hexColor){
    gameLib.setLineWidth(width);
    drawPerim_color(hexColor);
}
